<template>
	<el-dialog :title="title" :visible="editVisible" :close-on-click-modal="false" width="900px" :before-close="handleClose">
		<el-form ref="form" :rules="rules" :model="form" label-width="80px">
			<el-form-item label="用例名称" prop="case_name">
				<el-input v-model="form.case_name" ></el-input>
			</el-form-item>
			<el-form-item label="优先级" prop="priority">
				<el-input v-model="form.priority" ></el-input>
			</el-form-item>
			<el-form-item label="测试类型" prop="test_type">
				<el-input v-model="form.test_type" ></el-input>
			</el-form-item>
			<el-form-item label="测试模块" prop="test_module">
				<el-input v-model="form.test_module"></el-input>
			</el-form-item>
			<el-form-item label="测试前提" prop="test_premise">
				<el-input type="textarea" v-model="form.test_premise"></el-input>
			</el-form-item>
			<el-form-item label="测试步骤" prop="test_step">
				<el-input type="textarea" v-model="form.test_step"></el-input>
			</el-form-item>
			<el-form-item label="预期结果" prop="expect">
				<el-input type="textarea" v-model="form.expect"></el-input>
			</el-form-item>
		</el-form>
		<div slot="footer" class="dialog-footer">
			<el-button @click="editVisible = false">取 消</el-button>
			<el-button type="primary" @click="createProject">提 交</el-button>
		</div>
	</el-dialog>
</template>

<script>
import {orderCaseId} from '@/api/user'
export default {
	data(){
		return {
			editVisible:false,
			title:'修改用例',
			id:"",
			form:{},
			rules:{
				case_name:[{max: 100, message: '用例名称不能超过100个字符', trigger: 'blur'}],
				priority:[{max: 50, message: '优先级不能超过50个字符', trigger: 'blur'}],
				test_type:[{max: 50, message: '测试类型不能超过50个字符', trigger: 'blur'}],
				test_module:[{max: 50, message: '测试模块不能超过50个字符', trigger: 'blur'}],
				test_premise:[{max: 1000, message: '测试前提不能超过1000个字符', trigger: 'blur'}],
				test_step:[{max: 1000, message: '测试步骤不能超过1000个字符', trigger: 'blur'}],
				expect:[{max: 1000, message: '预期结果不能超过1000个字符', trigger: 'blur'}]
			}
		}
	},
	methods:{
		handleClose(){
			this.editVisible = false
		},
		createProject(){
			let id = this.id
			let data = this.form
			orderCaseId(data,id).then(res => {
				if(res.status == 'success'){
					this.$message.success('修改成功！')
					this.editVisible = false
					this.$parent.getDetail()
				}
				console.log(res,121212)
			})
		},
		initTab(data){
			this.id = data.id
			this.editVisible = true
			this.form = Object.assign({},data)
			console.log(data,12121)
		}
	}
}
</script>
